﻿DROP TRIGGER IF EXISTS  `pk_article_log`; 
CREATE  TRIGGER `pk_article_log` AFTER INSERT ON `open_article`
  FOR EACH ROW BEGIN
dECLARE pkf varchar(50) DEFAULT "";
sELECT pk_from INTO pkf FROM open_pk_log WHERE pk_from="article";
if pkf <> "article" then
  INSERT INTO open_pk_log SET pk_from = 'article', pk_id = NEW.article_id;
eLSE
   update open_pk_log SET pk_id = NEW.article_id WHERE pk_from = 'article';
end if;
end;